package mil.af.amc.adpetracker.model;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Comparator;

/**
 * Represents the model of a particular EquipmentItem
 *
 * @author TSgt Jason Ferguson
 */

@Entity
@Table(name="T_MODEL")
public class Model implements Serializable, Comparator<Model> {

    private int id;
    private String name;
    private Manufacturer manufacturer;
    private int processorSpeed;
    private byte[] image;

    @Id
    @Column(name="MODELID")
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Column(name="NAME")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @ManyToOne
    @JoinColumn(name="MANUFACTURERID")
    public Manufacturer getManufacturer() {
        return manufacturer;
    }

    public void setManufacturer(Manufacturer manufacturer) {
        this.manufacturer = manufacturer;
    }

    @Column(name="PROCESSORSPEED")
    public int getProcessorSpeed() {
        return processorSpeed;
    }

    public void setProcessorSpeed(int processorSpeed) {
        this.processorSpeed = processorSpeed;
    }

    @Lob
    @Column(name="IMAGE")
    public byte[] getImage() {
        return image;
    }

    public void setImage(byte[] image) {
        this.image = image;
    }

    public int compare(Model o1, Model o2) {
        return o1.getName().compareTo(o2.getName());
    }
}
